import 'package:flutter/material.dart';

class PrettyDialog extends StatelessWidget {
  final Widget content;
  final List<Widget> actions;
  final Image icon;
  final ImageProvider background;
  final Gradient gradient;

  PrettyDialog({this.content, this.actions, this.icon, this.background, this.gradient});

  @override
  Widget build(BuildContext context) {
    Decoration decoration;
    if (background != null) {
      decoration = BoxDecoration(
        gradient: gradient,
        borderRadius: BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)),
        image: DecorationImage(
          image: background,
          fit: BoxFit.fill,
        ),
      );
    }
    return Dialog(
      backgroundColor: Colors.transparent,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          AspectRatio(
            aspectRatio: 1.1/1,


            child: Container(
              decoration: decoration,
              child: Stack(
                children: [
                  Center(
                    child: icon,
                  ),
                  Positioned(
                    bottom: 16,
                    left: 10,
                    right: 10,
                    child: Center(
                      child: content,
                    ),
                  ),
                ],
              ),
            ),
          ),
          actions == null
              ? Divider(height: 0)
              : SizedBox.fromSize(
                  size: Size.fromHeight(56),
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.only(bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)),
                      color: Colors.white,
                    ),
                    child:  Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      children: actions,
                    ),
                  )
                ),
        ],
      ),
    );
  }
}
